package dataflowScheme.diagram.providers;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
import org.eclipse.gmf.runtime.notation.View;

/**
 * @generated
 */
public class ModelParserProvider extends AbstractProvider implements
		IParserProvider {

	/**
	 * @generated
	 */
	private IParser storageName_4003Parser;

	/**
	 * @generated
	 */
	private IParser getStorageName_4003Parser() {
		if (storageName_4003Parser == null) {
			storageName_4003Parser = createStorageName_4003Parser();
		}
		return storageName_4003Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createStorageName_4003Parser() {
		EAttribute[] features = new EAttribute[] { dataflowScheme.DataflowSchemePackage.eINSTANCE
				.getPE_Name(), };
		dataflowScheme.diagram.parsers.MessageFormatParser parser = new dataflowScheme.diagram.parsers.MessageFormatParser(
				features);
		parser.setViewPattern("Storage: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_4006Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_4006Parser() {
		if (taskName_4006Parser == null) {
			taskName_4006Parser = createTaskName_4006Parser();
		}
		return taskName_4006Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createTaskName_4006Parser() {
		EAttribute[] features = new EAttribute[] { dataflowScheme.DataflowSchemePackage.eINSTANCE
				.getPE_Name(), };
		dataflowScheme.diagram.parsers.MessageFormatParser parser = new dataflowScheme.diagram.parsers.MessageFormatParser(
				features);
		parser.setViewPattern("Task: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser dataPortName_4001Parser;

	/**
	 * @generated
	 */
	private IParser getDataPortName_4001Parser() {
		if (dataPortName_4001Parser == null) {
			dataPortName_4001Parser = createDataPortName_4001Parser();
		}
		return dataPortName_4001Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createDataPortName_4001Parser() {
		EAttribute[] features = new EAttribute[] { dataflowScheme.DataflowSchemePackage.eINSTANCE
				.getPort_Name(), };
		dataflowScheme.diagram.parsers.MessageFormatParser parser = new dataflowScheme.diagram.parsers.MessageFormatParser(
				features);
		parser.setViewPattern("D: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser synchroPortName_4002Parser;

	/**
	 * @generated
	 */
	private IParser getSynchroPortName_4002Parser() {
		if (synchroPortName_4002Parser == null) {
			synchroPortName_4002Parser = createSynchroPortName_4002Parser();
		}
		return synchroPortName_4002Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createSynchroPortName_4002Parser() {
		EAttribute[] features = new EAttribute[] { dataflowScheme.DataflowSchemePackage.eINSTANCE
				.getPort_Name(), };
		dataflowScheme.diagram.parsers.MessageFormatParser parser = new dataflowScheme.diagram.parsers.MessageFormatParser(
				features);
		parser.setViewPattern("S: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser dataPortName_4004Parser;

	/**
	 * @generated
	 */
	private IParser getDataPortName_4004Parser() {
		if (dataPortName_4004Parser == null) {
			dataPortName_4004Parser = createDataPortName_4004Parser();
		}
		return dataPortName_4004Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createDataPortName_4004Parser() {
		EAttribute[] features = new EAttribute[] { dataflowScheme.DataflowSchemePackage.eINSTANCE
				.getPort_Name(), };
		dataflowScheme.diagram.parsers.MessageFormatParser parser = new dataflowScheme.diagram.parsers.MessageFormatParser(
				features);
		parser.setViewPattern("D: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser synchroPortName_4005Parser;

	/**
	 * @generated
	 */
	private IParser getSynchroPortName_4005Parser() {
		if (synchroPortName_4005Parser == null) {
			synchroPortName_4005Parser = createSynchroPortName_4005Parser();
		}
		return synchroPortName_4005Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createSynchroPortName_4005Parser() {
		EAttribute[] features = new EAttribute[] { dataflowScheme.DataflowSchemePackage.eINSTANCE
				.getPort_Name(), };
		dataflowScheme.diagram.parsers.MessageFormatParser parser = new dataflowScheme.diagram.parsers.MessageFormatParser(
				features);
		parser.setViewPattern("S: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser synchroPortName_4007Parser;

	/**
	 * @generated
	 */
	private IParser getSynchroPortName_4007Parser() {
		if (synchroPortName_4007Parser == null) {
			synchroPortName_4007Parser = createSynchroPortName_4007Parser();
		}
		return synchroPortName_4007Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createSynchroPortName_4007Parser() {
		EAttribute[] features = new EAttribute[] { dataflowScheme.DataflowSchemePackage.eINSTANCE
				.getPort_Name(), };
		dataflowScheme.diagram.parsers.MessageFormatParser parser = new dataflowScheme.diagram.parsers.MessageFormatParser(
				features);
		parser.setViewPattern("S: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser synchroPortName_4009Parser;

	/**
	 * @generated
	 */
	private IParser getSynchroPortName_4009Parser() {
		if (synchroPortName_4009Parser == null) {
			synchroPortName_4009Parser = createSynchroPortName_4009Parser();
		}
		return synchroPortName_4009Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createSynchroPortName_4009Parser() {
		EAttribute[] features = new EAttribute[] { dataflowScheme.DataflowSchemePackage.eINSTANCE
				.getPort_Name(), };
		dataflowScheme.diagram.parsers.MessageFormatParser parser = new dataflowScheme.diagram.parsers.MessageFormatParser(
				features);
		parser.setViewPattern("S: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	protected IParser getParser(int visualID) {
		switch (visualID) {
		case dataflowScheme.diagram.edit.parts.StorageNameEditPart.VISUAL_ID:
			return getStorageName_4003Parser();
		case dataflowScheme.diagram.edit.parts.TaskNameEditPart.VISUAL_ID:
			return getTaskName_4006Parser();
		case dataflowScheme.diagram.edit.parts.DataPortNameEditPart.VISUAL_ID:
			return getDataPortName_4001Parser();
		case dataflowScheme.diagram.edit.parts.SynchroPortNameEditPart.VISUAL_ID:
			return getSynchroPortName_4002Parser();
		case dataflowScheme.diagram.edit.parts.DataPortName2EditPart.VISUAL_ID:
			return getDataPortName_4004Parser();
		case dataflowScheme.diagram.edit.parts.SynchroPortName2EditPart.VISUAL_ID:
			return getSynchroPortName_4005Parser();
		case dataflowScheme.diagram.edit.parts.SynchroPortName3EditPart.VISUAL_ID:
			return getSynchroPortName_4007Parser();
		case dataflowScheme.diagram.edit.parts.SynchroPortName4EditPart.VISUAL_ID:
			return getSynchroPortName_4009Parser();
		}
		return null;
	}

	/**
	 * @generated
	 */
	public IParser getParser(IAdaptable hint) {
		String vid = (String) hint.getAdapter(String.class);
		if (vid != null) {
			return getParser(dataflowScheme.diagram.part.ModelVisualIDRegistry
					.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(dataflowScheme.diagram.part.ModelVisualIDRegistry
					.getVisualID(view));
		}
		return null;
	}

	/**
	 * @generated
	 */
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (dataflowScheme.diagram.providers.ModelElementTypes
					.getElement(hint) == null) {
				return false;
			}
			return getParser(hint) != null;
		}
		return false;
	}

	/**
	 * @generated
	 */
	public static class HintAdapter extends ParserHintAdapter {

		/**
		 * @generated
		 */
		private final IElementType elementType;

		/**
		 * @generated
		 */
		public HintAdapter(IElementType type, EObject object, String parserHint) {
			super(object, parserHint);
			assert type != null;
			elementType = type;
		}

		/**
		 * @generated
		 */
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return elementType;
			}
			return super.getAdapter(adapter);
		}
	}

}
